package com.yundingai.service.impl;

import com.yundingai.domain.entity.StudyRoomConfig;
import com.yundingai.mapper.StudyRoomConfigMapper;
import com.yundingai.service.StudyRoomConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service

public class StudyRoomConfigServiceImpl implements StudyRoomConfigService {
    @Autowired
    private StudyRoomConfigMapper StudyRoomConfigMapper;
    @Autowired
    RedisTemplate redisTemplate;


    @Override
    public void updateStudyRoomConfig(StudyRoomConfig roomConfig) {




        roomConfig.setCreator("admin");
        roomConfig.setUpdateTime(new Date());

        StudyRoomConfigMapper.updateStudyRoomConfig(roomConfig);

    }

    @Override
    public StudyRoomConfig selectStudyRoomConfig() {
        StudyRoomConfig roomConfig = StudyRoomConfigMapper.selectStudyRoomConfig();
        redisTemplate.opsForValue().set("studyRoomConfig", roomConfig);
        return roomConfig;
    }
}
